<template>
  <div class="app-container">
  <el-card class="box-card">
      <el-form ref="form" :model="form" >

        <el-form-item label="统一社会信用代码" prop="creditCodes">
          <el-input v-model="form.creditCodes" placeholder="请输入统一社会信用代码" />
        </el-form-item>
        <el-form-item label="主要领导姓名" prop="leaderName">
          <el-input v-model="form.leaderName" placeholder="请输入主要领导姓名" />
        </el-form-item>
        <el-form-item label="主要领导职务" prop="leaderPosition">
          <el-input v-model="form.leaderPosition" placeholder="请输入主要领导职务" />
        </el-form-item>
        <el-form-item label="主要领导办公电话" prop="leaderBusinessPhone">
          <el-input v-model="form.leaderBusinessPhone" placeholder="请输入主要领导办公电话" />
        </el-form-item>
        <el-form-item label="主要领导移动电话" prop="leaderMobilePhone">
          <el-input v-model="form.leaderMobilePhone" placeholder="请输入主要领导移动电话" />
        </el-form-item>
        <el-form-item label="备注" prop="remark">
          <el-input v-model="form.remark" type="textarea" placeholder="请输入内容" />
        </el-form-item>

      </el-form>
    <br/>
    <div style="float:right; margin-bottom: 15px;">
      <el-button type="primary" @click="submitForm">确 定</el-button>
      <el-button @click="cancel">取 消</el-button>
    </div>

  </el-card>
  </div>
</template>
<style>
  .img-box1 {
    white-space: pre-wrap;
    width: 90%;

    position: center;
    margin:20px auto;
  }
  .img-box1 img {
    width: 70%;

    position: relative;
    left: 50%;
    transform: translateX(-50%);
  }
  .imgpre{
    width:200px;
    height: 100px;


  }
  .ifr{
    width: 70%;
    height: 700px;

    position: relative;
    left: 50%;
    transform: translateX(-50% );
  }


  .input_text input.el-input__inner {
    border: none
  }

  input:disabled{

    background-color: #F5F5F5;

    color:#F5F5F5;
  }

</style>
<script>
  import { listLeader, getLeader, delLeader, addLeader, updateLeader } from "@/api/system/leader";

  export default {
    name: "Leader",
    data() {
      return {
        // 传递过的数组
        carryCurrentRowCode: {},
        // 遮罩层
        loading: true,
        // 选中数组
        ids: [],
        // 非单个禁用
        single: true,
        // 非多个禁用
        multiple: true,
        // 显示搜索条件
        showSearch: true,
        // 总条数
        total: 0,
        // 承制单位领导信息表格数据
        leaderList: [],
        // 弹出层标题
        title: "",
        // 是否显示弹出层
        open: false,
        // 查询参数
        queryParams: {
          pageNum: 1,
          pageSize: 10,
          manufacturerId: null,
          creditCodes: null,
          leaderName: null,
          leaderPosition: null,
          leaderBusinessPhone: null,
          leaderMobilePhone: null,
          userId: null,
          deptId: null,
          createBy: null,
          createTime: null,
          updateBy: null,
          updateTime: null,
          remark: null,
          note1: null,
          note2: null,
          note3: null,
          note4: null,
          note5: null,
          note6: null,
          note7: null,
          note8: null,
          note9: null,
          note10: null
        },
        // 表单参数
        form: {},
        // 表单校验
        rules: {
        }
      };
    },
    created() {
      this.carryCurrentRowCode = this.$route.query.carryCurrentRowCode;
      this.form.creditCodes=this.carryCurrentRowCode.creditCodes;
      console.log(this.carryCurrentRowCode.creditCodes);

    },
    methods: {
      /** 查询承制单位领导信息列表 */
      getList() {
        this.loading = true;
        listLeader(this.queryParams).then(response => {
          this.leaderList = response.rows;
          this.total = response.total;
          this.loading = false;
        });
      },
      // 取消按钮
      cancel() {

      },
      // 表单重置
      reset() {
        this.form = {
          id: null,
          manufacturerId: null,
          creditCodes: null,
          leaderName: null,
          leaderPosition: null,
          leaderBusinessPhone: null,
          leaderMobilePhone: null,
          userId: null,
          deptId: null,
          createBy: null,
          createTime: null,
          updateBy: null,
          updateTime: null,
          remark: null,
          note1: null,
          note2: null,
          note3: null,
          note4: null,
          note5: null,
          note6: null,
          note7: null,
          note8: null,
          note9: null,
          note10: null
        };
        this.resetForm("form");
      },
      /** 搜索按钮操作 */
      handleQuery() {
        this.queryParams.pageNum = 1;
        this.getList();
      },
      /** 重置按钮操作 */
      resetQuery() {
        this.resetForm("queryForm");
        this.handleQuery();
      },
      // 多选框选中数据
      handleSelectionChange(selection) {
        this.ids = selection.map(item => item.id)
        this.single = selection.length!==1
        this.multiple = !selection.length
      },
      /** 新增按钮操作 */
      handleAdd() {
        this.reset();
        this.open = true;
        this.title = "添加承制单位领导信息";
      },
      /** 修改按钮操作 */
      handleUpdate(row) {
        this.reset();
        const id = row.id || this.ids
        getLeader(id).then(response => {
          this.form = response.data;
          this.open = true;
          this.title = "修改承制单位领导信息";
        });
      },
      /** 提交按钮 */
      submitForm() {
        this.$refs["form"].validate(valid => {
          if (valid) {
            if (this.form.id != null) {
              updateLeader(this.form).then(response => {
                this.$modal.msgSuccess("修改成功");
                this.open = false;
                this.getList();
              });
            } else {
              addLeader(this.form).then(response => {
                this.$modal.msgSuccess("新增成功");
                this.open = false;
                this.getList();

              });
              this.$router.push({ path: "/jiben/lsenterprise" });
              const obj = { path: "/jiben/lsenterprise"};
              this.$tab.closeOpenPage(obj);
            }
          }
        });
      },
      /** 删除按钮操作 */
      handleDelete(row) {
        const ids = row.id || this.ids;
        this.$modal.confirm('是否确认删除承制单位领导信息编号为"' + ids + '"的数据项？').then(function() {
          return delLeader(ids);
        }).then(() => {
          this.getList();
          this.$modal.msgSuccess("删除成功");
        }).catch(() => {});
      },
      /** 导出按钮操作 */
      handleExport() {
        this.download('system/leader/export', {
          ...this.queryParams
        }, `leader_${new Date().getTime()}.xlsx`)
      }
    }
  };
</script>





